package com.chinaV;


import com.chinaV.jedis.util.JedisConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.Jedis;

import java.util.Map;

public class JedisTest2 {

    private Jedis jedis;

    @BeforeEach
    void setUp(){
        jedis = JedisConnectionFactory.getJedis();

        jedis.select(1);



    }

    @Test
    void testString(){
        String res = jedis.set("name", "yw");
        System.out.println(res);

        String name = jedis.get("name");
        System.out.println(name);

    }

    @Test
    void testHash(){
        jedis.hset("user:1","name","yw");
        jedis.hset("user:1","age","21");

        Map<String, String> res = jedis.hgetAll("user:1");
        System.out.println(res);

    }


    @AfterEach
    void close(){
        if (jedis != null)
            jedis.close();
    }

}
